package com.hdu.controller.collegeManagement;


import com.hdu.pojo.Result;
import com.hdu.service.IWeatherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 天气实体类 前端控制器
 * </p>
 *
 * @author xiaobai
 * @since 2023-12-04
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@Api(tags = "天气管理接口")
@RequestMapping("/weather")
public class WeatherController {

    private final IWeatherService weatherService;

    @ApiOperation("获取全国平均温度列表")
    @GetMapping
    public Result<?> avg(String name, String time) {
        log.info("name:{},time:{}", name, time);
        return Result.success(weatherService.avg(name, time));
    }

    @ApiOperation("获取全国省份城市导航")
    @GetMapping("/region")
    public Result<?> region() {
        return Result.success(weatherService.region());
    }

    @ApiOperation("获取全国学校所在省市")
    @GetMapping("/school")
    public Result<?> school() {
        return Result.success(weatherService.school());
    }

    @ApiOperation("获取省市天气详细情况")
    @GetMapping("/{name}")
    public Result<?> weather(@PathVariable String name) {
        return Result.success(weatherService.weather(name));
    }
}
